﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MyTime.ProviderFactory.Entities;

namespace MyTime.WPF.Units
{
    /// <summary>
    /// Interaction logic for TimeItem.xaml
    /// </summary>
    public partial class TimeItem : UserControl
    {
        public TimeItem()
        {
            InitializeComponent();
        }
        public TimeItem(ITimeItem timeItem, TimeSpan timeSpent)
        {
            InitializeComponent();
            MessageLabel.Text = timeItem.Task;
            MessageLabel.ToolTip = string.Format("{0:hh\\:mm} - {1:hh\\:mm}", timeItem.StartTime, timeItem.EndTime);
            HourLabel.Content = string.Format("{0:hh\\:mm}", timeSpent);
            MessageLabel.MouseDoubleClick += MessageLabel_MouseDoubleClick;
        }

        void MessageLabel_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            MessageLabel.SelectAll();
            Clipboard.SetText(MessageLabel.SelectedText);
        }
    }
}
